package com.example.werthwedemo0309.fragment;

import android.content.Intent;
import android.os.Bundle;

import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.werthwedemo0309.MainActivity;
import com.example.werthwedemo0309.R;
import com.example.werthwedemo0309.twoActivity;


public class CityFragment extends Fragment {
    private View root;
    private RecyclerView recyclerView;
    private TextView text_du;
    private TextView text2;
    private TextView text_city;
    private ImageView image_add;
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        root= inflater.inflate(R.layout.fragment_city, container, false);
        initVirw();
        return root;

    }

    private void initVirw() {
//        recyclerView=root.findViewById(R.id.Recycler);
//        //网格列表
//        GridLayoutManager glm = new GridLayoutManager(getActivity(), 3, GridLayoutManager.HORIZONTAL, false);
//        recyclerView.setLayoutManager(glm);
         text_du = root.findViewById(R.id.text_du);
         text2 = root.findViewById(R.id.text2);
         text_city = root.findViewById(R.id.text_city);
         image_add= root.findViewById(R.id.image_add);
         text_du.setText(MainActivity.response.body().getResult().getRealtime().getTemperature());
         text2.setText(MainActivity.response.body().getResult().getRealtime().getInfo());
         text_city.setText(MainActivity.response.body().getResult().getCity());
         image_add.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
                 Intent intent=new Intent(getActivity(), twoActivity.class);
                 startActivity(intent);
             }
         });
    }
}